package com.esri.android.map.ags;

import com.esri.core.ags.LayerServiceInfo;
import com.esri.core.internal.util.d;
import com.esri.core.map.Legend;
import com.github.mikephil.charting.utils.Utils;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;

/* loaded from: classes.dex */
public class ArcGISLayerInfo implements Serializable {
    private static final long serialVersionUID = 1;
    String a;
    int b;
    ArcGISLayerInfo c;
    boolean d;
    double e = Utils.DOUBLE_EPSILON;
    double f = Utils.DOUBLE_EPSILON;
    final ArrayList<ArcGISLayerInfo> g = new ArrayList<>();
    boolean h = true;
    List<Legend> i;
    String j;
    LayerServiceInfo k;

    public LayerServiceInfo getLayerServiceInfo() {
        return this.k;
    }

    public ArcGISLayerInfo() {
    }

    public ArcGISLayerInfo(String str, int i) {
        this.a = str;
        this.b = i;
    }

    public ArcGISLayerInfo(String str, int i, ArcGISLayerInfo arcGISLayerInfo) {
        this.a = str;
        this.b = i;
        this.c = arcGISLayerInfo;
    }

    public ArcGISLayerInfo[] getLayers() {
        ArrayList<ArcGISLayerInfo> arrayList = this.g;
        if (arrayList == null) {
            return null;
        }
        return (ArcGISLayerInfo[]) arrayList.toArray(new ArcGISLayerInfo[0]);
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void a(ArcGISLayerInfo arcGISLayerInfo) {
        this.g.add(arcGISLayerInfo);
    }

    public boolean isVisible() {
        return this.d;
    }

    public void setVisible(boolean z) {
        this.d = z;
    }

    public String getName() {
        return this.a;
    }

    public int getId() {
        return this.b;
    }

    public ArcGISLayerInfo getParentLayer() {
        return this.c;
    }

    public double getMinScale() {
        return this.e;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void a(double d) {
        this.e = d;
    }

    public double getMaxScale() {
        return this.f;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void b(double d) {
        this.f = d;
    }

    public List<Legend> getLegend() {
        return this.i;
    }

    public void setLegend(List<Legend> list) {
        this.i = list;
    }

    public boolean isShowLegend() {
        if (getParentLayer() != null) {
            return b(getParentLayer()) & this.h;
        }
        return this.h;
    }

    private boolean b(ArcGISLayerInfo arcGISLayerInfo) {
        if (arcGISLayerInfo.getParentLayer() != null) {
            return b(arcGISLayerInfo.getParentLayer());
        }
        return arcGISLayerInfo.h;
    }

    public String toString() {
        return "ArcGISLayerInfo [name=" + this.a + ", id=" + this.b + ", visible=" + this.d + ", minScale=" + this.e + ", maxScale=" + this.f + ",isShowLegend=" + this.h + "]";
    }

    public static ArcGISLayerInfo fromJson(JsonParser jsonParser) throws Exception {
        if (d.c(jsonParser)) {
            ArcGISLayerInfo arcGISLayerInfo = new ArcGISLayerInfo();
            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                String currentName = jsonParser.getCurrentName();
                jsonParser.nextToken();
                if ("layerId".equals(currentName)) {
                    arcGISLayerInfo.b = jsonParser.getIntValue();
                } else if ("layerName".equals(currentName)) {
                    arcGISLayerInfo.a = jsonParser.getText();
                } else if ("layerType".equals(currentName)) {
                    arcGISLayerInfo.j = jsonParser.getText();
                } else if ("minScale".equals(currentName)) {
                    arcGISLayerInfo.e = jsonParser.getDoubleValue();
                } else if ("maxScale".equals(currentName)) {
                    arcGISLayerInfo.f = jsonParser.getDoubleValue();
                } else if ("legend".equals(currentName)) {
                    ArrayList arrayList = new ArrayList();
                    if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
                        while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                            arrayList.add(Legend.fromJson(jsonParser));
                        }
                    }
                    arcGISLayerInfo.setLegend(arrayList);
                } else {
                    jsonParser.skipChildren();
                }
            }
            return arcGISLayerInfo;
        }
        return null;
    }
}
